﻿module Sustainalytics.LRTM {

    // service for interacting with Long Running Tasks
    export interface ILongRunningTaskService {

        //#region POST

        // post
        post(
            id: string,
            title: string,
            paramJson: string,
            taskType: LongRunningTaskTypeEnum,
            fileName: string,
            mimeType: string,
            files: any[],
            uploadProgressFunc: (number) => void,
            isUpload: boolean,
            isDownload: boolean,
            order: number): LongRunningTaskInstancePost;

        // run task without upload for current user
        postTask(
            id: string,
            title: string,
            paramJson: string,
            taskType: LongRunningTaskTypeEnum,
            isDownload: boolean,
            order: number): LongRunningTaskInstancePost;

        // run task with file upload for current user
        postTaskWithUpload(
            id: string,
            title: string,
            paramJson: string,
            taskType: LongRunningTaskTypeEnum,
            files: any[],
            uploadProgressFunc: (number) => void,
            isDownload: boolean,
            order: number): LongRunningTaskInstancePost;

        //#endregion


        //#region GET

        // get
        get(taskInstanceId: string, overallStatus: boolean, getStatus: boolean, getResult: boolean, deleteOnGetResult: boolean): ng.IHttpPromise<any>;

        // get overall status for current user
        getOverallStatus(): ng.IPromise<LongRunningTaskInstanceStatus[]>;

        // get status for a specific task instance ID
        getStatus(taskInstanceId: string): ng.IPromise<LongRunningTaskInstanceStatus>;

        // get task instance result as an object
        getResultAsObject(taskInstanceId: string, deleteOnGetResult: boolean): ng.IPromise<any>;

        // get task instance result as a download
        getResultAsDownload(taskInstanceId: string, deleteOnGetResult: boolean): void;

        //#endregion


        //#region DELETE

        // delete
        deleteTaskInstance(taskInstanceId: string): ng.IHttpPromise<any>;

        //#endregion
    }
}